package cn.sherer.beans;

import java.util.List;
import java.util.Arrays;

/**
 * 结果
 */
public class Result {
    private Object code;
    private String msg;
    private Object data;
    private String requestId;
    private String token;
    private long tokenExpired;
    private boolean needRefresh;
    private List<String> permission;

    public Result() {
    }

    public void set(Object code) {
        this.code = code;
    }

    public void set(Object code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public void set(Object code, String msg, Object data) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public void set(String token, long tokenExpired) {
        this.token = token;
        this.tokenExpired = tokenExpired;
    }

    public Result(Object code) {
        this.code = code;
    }

    public Result(Object code, String msg) {
        this(code);
        this.msg = msg;
    }

    public Result(Object code, String msg, Object data) {
        this(code, msg);
        this.data = data;
    }

    public Result(Object code, String msg, Object data, String requestId) {
        this(code, msg, data);
        this.requestId = requestId;
    }

    public Result(Object code, String msg, Object data, String requestId, String token, long tokenExpired) {
        this(code, msg, data, requestId);
        this.token = token;
        this.tokenExpired = tokenExpired;
    }

    public Result(Object code, String msg, Object data, String requestId, String token, long tokenExpired, boolean needRefresh) {
        this(code, msg, data, requestId, token, tokenExpired);
        this.needRefresh = needRefresh;
    }

    public Result(Object code, String msg, Object data, String requestId, String token, long tokenExpired, boolean needRefresh, List<String> permission) {
        this(code, msg, data, requestId, token, tokenExpired, needRefresh);
        this.permission = permission;
    }

    public Object getCode() {
        return code;
    }

    public void setCode(Object code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public long getTokenExpired() {
        return tokenExpired;
    }

    public void setTokenExpired(long tokenExpired) {
        this.tokenExpired = tokenExpired;
    }

    public boolean isNeedRefresh() {
        return needRefresh;
    }

    public void setNeedRefresh(boolean needRefresh) {
        this.needRefresh = needRefresh;
    }

    public List<String> getPermission() {
        return permission;
    }

    public void setPermission(List<String> permission) {
        this.permission = permission;
    }

    @Override
    public String toString() {
        return "Result{" + "code=" + code + ", msg=" + msg + ", data=" + data + ", requestId=" + requestId + ", token=" + token + ", tokenExpired=" + tokenExpired + ", needRefresh=" + needRefresh + ", permission=" + Arrays.toString(permission.toArray()) + '}';
    }
}
